<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/admin/";
%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE>
<html>
<head>
<base href="<%=basePath%>" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link href="assets/css/bootstrap.min.css" rel="stylesheet" />
<link rel="stylesheet" href="css/style.css" />
<link href="assets/css/codemirror.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/ace.min.css" />
<link rel="stylesheet" href="font/css/font-awesome.min.css" />
<!--[if lte IE 8]>
		  <link rel="stylesheet" href="assets/css/ace-ie.min.css" />
		<![endif]-->
<script src="js/jquery-1.9.1.min.js"></script>
<script src="assets/js/typeahead-bs2.min.js"></script>
<script src="js/lrtk.js" type="text/javascript"></script>
<script src="assets/js/jquery.dataTables.min.js"></script>
<script src="assets/js/jquery.dataTables.bootstrap.js"></script>
<script src="assets/layer/layer.js" type="text/javascript"></script>
<script src="assets/dist/echarts.js"></script>

<title>会员等级</title>
</head>
<body>
	<div class="grading_style">
		<div id="category">
			<div id="scrollsidebar" class="left_Treeview">
				<div class="show_btn" id="rightArrow">
					<span></span>
				</div>
				<div class="widget-box side_content">
					<div class="side_title">
						<a title="隐藏" class="close_btn"><span></span></a>
					</div>
					<div class="side_list">
						<div class="widget-header header-color-green2">
							<h4 class="lighter smaller">会员等级</h4>
						</div>
						<div class="widget-body">
							<ul class="b_P_Sort_list">
								<li><i class="orange  fa fa-user-secret"></i><a href="#">全部(${ucount})</a></li>
								<c:forEach items="${ranks}" var="rank">
									<li><i class="fa fa-diamond pink "></i> <a
										href="/userRanks/selectByExample?rankid=${rank.rankid}">${rank.rankname}(${rank.nums})</a></li>
								</c:forEach>
							</ul>
						</div>
					</div>
				</div>
			</div>
			<!--右侧样式-->
			<div class="page_right_style right_grading">
				<div class="Statistics_style" id="Statistic_pie">
					<div class="type_title">
						等级统计 <span class="top_show_btn Statistic_btn">显示</span> <span
							class="Statistic_title Statistic_btn"><a title="隐藏"
							class="top_close_btn">隐藏</a></span>
					</div>
					<div id="Statistics" class="Statistics"></div>
				</div>
				<!--列表样式-->
				<div class="grading_list">
					<div class="type_title">全部会员等级列表</div>
					<div class="table_menu_list">
						<table class="table table-striped table-bordered table-hover"
							id="sample-table">
							<thead>
								<tr>
									<th width="25"><label><input type="checkbox"
											class="ace"><span class="lbl"></span></label></th>
									<th width="80">ID</th>
									<th width="100">用户名</th>
									<th width="80">性别</th>
									<th width="120">手机</th>
									<th width="150">邮箱</th>

									<th width="180">加入时间</th>
									<th width="100">等级</th>
									<th width="100">积分</th>
									<th width="70">状态</th>
									<th width="250">操作</th>
								</tr>
							</thead>
							<tbody>
								<c:forEach items="${pageInfo.list}" var="ls">
									<tr>
										<td><label><input type="checkbox" class="ace"><span
												class="lbl"></span></label></td>
										<td>${ls.userid}</td>
										<td><u style="cursor: pointer" class="text-primary"
											onclick="member_show('${ls.username}','/users/selectByPrimaryKey','${ls.userid}','500','400')">${ls.username}</u></td>
										<c:if test="${ls.usersex==0}">
											<td>男</td>
										</c:if>
										<c:if test="${ls.usersex==1}">
											<td>女</td>
										</c:if>
										<td>${ls.userphone}</td>
										<td>${ls.useremail}</td>
										<td><fmt:formatDate value="${ls.createtime}"
												pattern="yyyy-MM-dd HH:mm:ss" /></td>
										<td>${ls.rank.rankname}</td>
										<td class="text-l">${ls.userscore}</td>
										<td class="td-status"><c:if test="${ls.userstaus==1}">
												<span class="label label-success radius">正常</span>
											</c:if> <c:if test="${ls.userstaus==0}">
												<span style="background-color: red;" class="label radius">冻结</span>
											</c:if></td>
										<td class="td-manage"><c:if test="${ls.userstaus==1}">
												<a
													onClick="member_stop(this,'10001',${ls.userid},${ls.userstaus})"
													href="javascript:;" title="冻结"
													class="btn btn-xs btn-success"><i
													class="fa fa-check  bigger-120"></i></a>
											</c:if> <c:if test="${ls.userstaus==0}">
												<a
													onClick="member_start(this,'10001',${ls.userid},${ls.userstaus})"
													href="javascript:;" title="解冻" class="btn btn-xs btn-error"><i
													class="fa fa-check  bigger-120"></i></a>
											</c:if></td>
									</tr>
								</c:forEach>
							</tbody>
						</table>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>
<script type="text/javascript"> 
$(function() { 
	$("#category").fix({
		float : 'left',
		//minStatue : true,
		skin : 'green',	
		durationTime :false,
		spacingw:20,
		spacingh:240,
		set_scrollsidebar:'.right_grading',
	});
});
$(function() { 
	$("#Statistic_pie").fix({
		float : 'top',
		//minStatue : true,
		skin : 'green',	
		durationTime :false,
		spacingw:0,
		spacingh:0,
		close_btn:'.top_close_btn',
		show_btn:'.top_show_btn',
		side_list:'.Statistics',
		close_btn_width:80,
		side_title:'.Statistic_title',
	});
});
/*用户-查看*/
function member_show(title,url,id,w,h){
	layer_show(title,url+'#?='+id,w,h);
}
/*用户-停用*/
/*用户-停用*/
function member_stop(obj,id,uid,staus){
	layer.confirm('确认要冻结吗？',function(index){

		$.ajax({
			url:"/users/updateByPrimaryKeySelective?userid="+uid+"&userStaus="+staus,
			type:"get",
			data:"",
			dataType:"json",
			success:function(data){
				if(data){
					layer.msg('已冻结!',{icon: 5,time:1000});
					setTimeout(function(){
						location.href="/userRanks/selectByExample";
					}, 1000);
            	}else{
            		layer.msg('冻结失败',{icon:2,time:1000});
            		return;
            	}
			},
			error:function(){
				alert("ajax创建失败！");
			},
		});
	});
}

/*用户-启用*/
function member_start(obj,id,uid,staus){
	layer.confirm('确认要解冻吗？',function(index){
		$.ajax({
			url:"/users/updateByPrimaryKeySelective?userid="+uid+"&userStaus="+staus,
			type:"get",
			data:"",
			dataType:"json",
			success:function(data){
				if(data){
					layer.msg('解冻成功!',{icon: 6,time:1000});
					setTimeout(function(){
						location.href="/userRanks/selectByExample";
					}, 1000);
            	}else{
            		layer.msg('解冻失败',{icon:2,time:1000});
            		return;
            	}
			},
			error:function(){
				alert("ajax创建失败！");
			},
		});
		
	});
	
}

/* function show(){
		$.ajax({
			url:"/userRanks/selectByExample?rankid=",
			type:"get",
			data:"",
			dataType:"json",
			success:function(data){
				if(data){
				
            	}else{
            		return;
            	}
			},
			error:function(){
				alert("ajax创建失败！");
			},
		});
} */
</script>
<script type="text/javascript">

//初始化宽度、高度  
 $(".widget-box").height($(window).height()); 
 $(".page_right_style").width($(window).width()-220);
 //$(".table_menu_list").width($(window).width()-240);
  //当文档窗口发生改变时 触发  
    $(window).resize(function(){
	$(".widget-box").height($(window).height());
	 $(".page_right_style").width($(window).width()-220);
	 //$(".table_menu_list").width($(window).width()-240);
	}) 
/**************/
     require.config({
            paths: {
                echarts: './assets/dist'
            }
        });
        require(
            [
                'echarts',
				'echarts/theme/macarons',
                'echarts/chart/pie',   // 按需加载所需图表，如需动态类型切换功能，别忘了同时加载相应图表
                'echarts/chart/funnel'
            ],
            function (ec,theme) {
                var myChart = ec.init(document.getElementById('Statistics'),theme);
			option = {
    title : {
        text: '用户等级统计',
        subtext: '实时更新最新等级',
        x:'center'
    },
    tooltip : {
        trigger: 'item',
        formatter: "{a} <br/>{b} : {c} ({d}%)"
    },
    legend: {
        
        x : 'center',
        y : 'bottom',
        data:['普通用户','铁牌用户','铜牌用户','银牌用户','金牌用户','钻石用户','蓝钻用户','红钻用户']
    },
    toolbox: {
        show : true,
        feature : {
            mark : {show: false},
            dataView : {show: false, readOnly: true},
            magicType : {
                show: true, 
                type: ['pie', 'funnel'],
                option: {
                    funnel: {
                        x: '25%',
                        width: '50%',
                        funnelAlign: 'left',
                        max: 6200
                    }
                }
            },
            restore : {show: true},
            saveAsImage : {show: true}
        }
    },
    calculable : true,
    series : [
        {
            name:'品牌数量',
            type:'pie',
            radius : '55%',
            center: ['50%', '60%'],
            data:[
                
                {value:1200, name:'普通用户'},
                {value:1100, name:'铁牌用户'},
				{value:1300, name:'铜牌用户'},
				{value:1000, name:'银牌用户'},
				{value:980, name:'金牌用户'},
				{value:850, name:'钻石用户'},
				{value:550, name:'蓝钻用户'},
				{value:220, name:'红钻用户'},

            ]
        }
    ]
};
   myChart.setOption(option);
			}
);
</script>
<script type="text/javascript">
$(function($) {
				var oTable1 = $('#sample-table').dataTable( {
				"aaSorting": [[ 1, "desc" ]],//默认第几个排序
		"bStateSave": true,//状态保存
		"aoColumnDefs": [
		  //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
		  {"orderable":false,"aTargets":[0,2,3,4,5,6,7,9]}// 制定列不参与排序
		] } );
				
				
				$('table th input:checkbox').on('click' , function(){
					var that = this;
					$(this).closest('table').find('tr > td:first-child input:checkbox')
					.each(function(){
						this.checked = that.checked;
						$(this).closest('tr').toggleClass('selected');
					});
						
				});
			
			
				$('[data-rel="tooltip"]').tooltip({placement: tooltip_placement});
				function tooltip_placement(context, source) {
					var $source = $(source);
					var $parent = $source.closest('table')
					var off1 = $parent.offset();
					var w1 = $parent.width();
			
					var off2 = $source.offset();
					var w2 = $source.width();
			
					if( parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2) ) return 'right';
					return 'left';
				}
			});
</script>
